package com.service.impl;

import com.dao.IPhonedao;
import com.dao.impl.Phonedaoimpl;
import com.entity.Phone;
import com.service.IPhoneService;

import java.sql.SQLException;
import java.util.List;

public class PhoneServiceimpl implements IPhoneService {
    IPhonedao dao=new Phonedaoimpl();

    @Override
    public Integer UpdatePhone(Phone phone) {
        Integer integer = dao.UpPhoneData(phone);
        return integer;
    }

    @Override
    public Integer AddPhone(Phone phone) {
        return null;
    }

    @Override
    public Integer UpdatePhonePurchase(Integer id) {
        Integer integer = null;
        try {
            integer = dao.UpPhoneState(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return integer;
    }

    @Override
    public List<Phone> findAll() {
        List<Phone> allphon = null;
        try {
            allphon = dao.findAllPhone();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return allphon;
    }

    @Override
    public Phone findById(Integer id) {
        Phone phone=null;
        try {
            phone = dao.findByIdPhone(id);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return phone;
    }

    @Override
    public Integer findPValue(Integer id) {
        Integer i = dao.findValue(id);
        return i;
    }

    @Override
    public Integer UpDatePValue(Integer value, Integer id) {
        Integer integer = dao.UpDateValue(value, id);
        return integer;
    }
}
